#include "draw2d.h"
#include "tgaimage.h"
#include "model.h"

int main(int argc,char** argv)
{
    TGAImage *image=new TGAImage(800,600,3);
    Model *model;
    Draw2d* draw;
    TGAColor white(255,255,255,255);
    if(argc==2)
    {
        model=new Model(argv[1]);
    }
    else 
    {
        model=new Model("obj/african_head.obj");
    }
    for(int i=0;i<model->nfaces();i++)
    {
        std::vector<int> face=model->face(i);
        Vec2i screen_coords[3];
        for(int j=0;j<3;j++)
        {
            Vec3f v=model->vert(face[j]);
            screen_coords[j]=Vec2i((v.x+1.)*400.,(v.y+1.)*300.);
        }
        draw->fillcolor(image,screen_coords[0],screen_coords[1],screen_coords[2],white);
    }
    image->flip_vertically();
    image->write_tga_file("wireframe_fill_1.tga");
    return 0;
}